#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <map>
#include <deque>

using namespace std;

class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
		string a;
		int strSize = strs.size();
		for(int i = 0; i < strs[0].size(); i++){
			char head = strs[0][i];
			for(int j = 0; j < strSize; j++){
				if(head != strs[j][i]){
					return a;
				}
				if(head == strs[j][i] && j == strSize - 1){
					a.push_back(head);
				}
			}
		}
		return a;
    }
};

int main(){
	Solution so;
	vector<string> input = {"flower","flow","flight"};
	string a = so.longestCommonPrefix(input);
	
	cout << "max:" << a << endl;
	return 0;
}